<?php

function tf_postcontainer_code($thisTemplate) {
  global $thfr_css;

  $thisCon = $thfr_css[$thisTemplate]['usepostcontainer'];
  extract($thfr_css['postcontainers'][$thisCon]);

  if (in_array($thisTemplate, array('index', 'category', 'archive'))) {
    $headlinecode = str_replace(array('h1'), array('h2'), $headlinecode);
  }

  if ($thisTemplate == 'page') {
    $addClass = "'post'";
  }
  else
  {
    $addClass = '';
  }

  $aContents = array(
    'post_class' => ' <?php post_class(' . $addClass . ') ?>',
    'post_id' => ' id="post-<?php the_ID(); ?>"',
    'the_excerpt' => '<?php the_excerpt(); ?>',
    'kickercheck' => $kickercheck,
    'kickercode' => $kickercode,
    'headlinecheck' => $headlinecheck,
    'headlinecode' => $headlinecode,
    'bylinecheck' => $bylinecheck,
    'bylinecode' => $bylinecode,
    'contentcheck' => $contentcheck,
    'content_class' => ' class="post-bodycopy clearfix"',
    'contenttype' => $contenttype,
    'thecontent' => $thecontent,
    'linkpages' => $linkpages,
    'footercheck' => $footercheck,
    'footercode' => $footercode,
    'drop_area_beforePostTitle' => get_drop_areas($thisTemplate, "beforePostTitle"),
    'drop_area_beforePost' => get_drop_areas($thisTemplate, "beforePost"),
    'drop_area_afterPostTitle' => get_drop_areas($thisTemplate, "afterPostTitle"),
    'drop_area_afterPost' => get_drop_areas($thisTemplate, "afterPost"),
  );
  $string = tf_common_template_postcontainer_section($aContents);

  if ($thumbcheck == 'on') {
    // Add Thumb Code:
    /*
    $thumbcode = '<?php if( function_exists("the_post_thumbnail") AND !function_exists("tfe_get_image") ) the_post_thumbnail( "thumbnail", array("class" => "align' . $thumbalign . ' postthumb") ); ?>';
    */

    $thumbcode = '<?php if( function_exists("vp_getFirstPostImageUrl")) echo vp_getFirstPostImageUrl("", "", true); ?>';

    $thumbcode .= get_drop_areas($thisTemplate, "afterThumbnail");
    $string = str_replace('%thumbpos-' . $thumbpos . '%', $thumbcode, $string);
  }

  // Remove remaining Thumb placeholders
  $string = preg_replace("/%thumbpos-(.*)%/i", "", $string);

  return $string;
}

?>